import java.util.Random;

public class PingpangSporter extends Sporter implements EnglishSpeakable , Studyable{
    private int matchCount;
    private int winCount;

    public PingpangSporter() {
    }

    public PingpangSporter(String name, int age) {
        super(name, age);
        this.matchCount = 0;
        this.winCount = 0;
    }
    @Override
    public void train() {
        System.out.println("我正在进行乒乓球训练，挥拍、接球、发球...");
        Random random = new Random();
        int trainingIntensity = random.nextInt(10) + 1;
        System.out.println("本次训练强度为：" + trainingIntensity);
    }
    @Override
    public void study() {
        System.out.println("我正在学习乒乓球的新技巧。");
    }

    @Override
    public void speakEnglish() {
        System.out.println("我会说英语，Hello, table tennis!");
    }

    public void participateMatch() {
        // 模拟乒乓球比赛
        //Random random1 = new Random();
        //matchCount += random1.nextInt(5)+5;
        matchCount++;
        Random random = new Random();
        boolean isWin = random.nextBoolean();
        if (isWin) {
            //Random random2 = new Random();
            //winCount += random2.nextInt(2)+3;
            winCount++;
            System.out.println("在本次乒乓球比赛中，" + getName() + " 获胜了！");
        } else {
            System.out.println("在本次乒乓球比赛中，" + getName() + " 遗憾落败。");
        }
    }
         // 显示比赛统计信息
    public void showMatchStats() {
        System.out.println(getName() + " 参加了 " + matchCount + " 场比赛，赢了 " + winCount + " 场。");
    }

}
